/*
	libsimple_graphical - unambitious C++ graphical library
	https://notabug.org/namark/libsimple_graphical
	https://gitlab.com/namark/libsimple_graphical
	https://github.com/namark/libsimple_graphical

	Copyright (C) 2017-2019 respective authors/contributors

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SIMPLE_GRAPHICAL_PALETTE_VIEW_H
#define SIMPLE_GRAPHICAL_PALETTE_VIEW_H

#include <SDL2/SDL.h>
#include "simple/support/range.hpp"
#include "color.h"

namespace simple::graphical
{

	class palette_view
	{
		using range = support::range<const rgba_pixel*>;

		public:
		size_t size() const noexcept;

		size_t set_colors(range colors, size_t start_index = 0) const noexcept;
		template<typename Range>
		size_t set_colors(const Range& colors, size_t start_index = 0) const noexcept
		{ return set_colors({colors.begin(), colors.end()}, start_index); }

		rgba_pixel operator[](size_t index) const noexcept;
		rgba_pixel at(size_t index) const;

		private:
		SDL_Palette* raw;
		explicit palette_view(SDL_Palette* raw) noexcept;
		friend class pixel_format;
	};

} // namespace simple::graphical

#endif /* end of include guard */
